/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   09.05.2010
 * @version SVN: $Id: RecipeIngredient.java 128 2010-05-13 22:09:20Z christian-kerl@web.de $
 */
package org.cakis.server.model;

import java.io.Serializable;

import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Version;

/**
 * RecipeIngredient
 *
 * @author Christian Kerl
 */
@Entity
public class RecipeIngredient implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private Integer version;

    private Recipe recipe;
    private BaseProduct product;
    private String hint;
    private ProductQuantity quantity = new ProductQuantity();

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    @SuppressWarnings("unused")
    private void setVersion(Integer version) {
        this.version = version;
    }

    @ManyToOne
    public Recipe getRecipe() {
        return recipe;
    }

    public void setRecipe(Recipe recipe) {
        this.recipe = recipe;
    }

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    public BaseProduct getProduct() {
        return product;
    }

    public void setProduct(BaseProduct product) {
        this.product = product;
    }

    @Embedded
    public ProductQuantity getQuantity() {
        return quantity;
    }

    public void setQuantity(ProductQuantity quantity) {
        this.quantity = quantity;
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }
}
